new Vue({
	el: "body",
	data: {
		objectid: "",
		show: true,
		grxx: false,
		qzyx: false,
		zwpj: false,
		resumeName: "", //简历名称
		username: "", //姓名
		sex: "男", //性别（默认为男）
		isman: true, //是男人
		iswoman: false, //是女人
		birthday: "", //生日
		hukou: "", //户口
		city: "", //居住城市
		telephone: "", //手机号
		email: "", //邮箱
		school: "", //毕业学校
		workplace: "", //工作地点
		jobtypelist: ["销售", "客服", "市场", "财务", "人力资源", "行政", "项目", "质量", "高级管理", "IT", "互联网", "通信", "房产", "建筑", "物业管理", "金融", "采购", "贸易", "交通", "物流", "生产", "制造", "传媒", "印刷", "艺术", "设计", "咨询", "法律", "教育", "翻译", "服务业", "能源", "环保", "农业", "科研", "兼职", "实习", "社工", "其他"],
		jobtype: "职位类别",
		jobtypelistShow: false,
		industrylist: ["软件", "环保", "航空", "政府", "银行", "贸易", "科研", "网游", "工控", "物流", "租赁", "通讯", "电子", "化工", "媒体", "硬件", "机电", "IT服务", "旅游", "建筑"],
		industry: "行业类别",
		industrylistShow: false,
		moneylist: ["1500以下", "1500-4000元/月", "4001-6000元/月", "6001-8000元/月", "8001-10000元/月", "10001元/月以上"],
		money: "薪资类别",
		moneylistShow: false,
	},
	methods: {
		jobType: function(index) { //选择职位类型
			var jobtype = this.jobtypelist[index];
			this.jobtype = jobtype;
			this.jobtypelistShow = false;

		},
		job: function() { //弹出职位列表
			this.industrylistShow = false;
			this.moneylistShow = false;
			this.jobtypelistShow = true;
		},
		indusTry: function(index) { //选择行业类型
			var industry = this.industrylist[index];
			this.industry = industry;
			this.industrylistShow = false;
		},
		ind: function() { //弹出行业列表
			this.industrylistShow = true;
			this.jobtypelistShow = false;
			this.moneylistShow = false;
		},
		mone: function(index) { //选择薪资类型
			var moneylist = this.moneylist[index];
			this.money = moneylist;
			this.moneylistShow = false;
		},
		mon: function() { //弹出薪资列表
			this.moneylistShow = true;
			this.jobtypelistShow = false;
			this.industrylistShow = false;
		},
		quxiao: function() {
			this.moneylistShow = false;
			this.jobtypelistShow = false;
			this.industrylistShow = false;
		},
		resumeBj: function() {
			this.grxx = true;
			this.show = false;
			$("#zwpj").html(this.zwpj);
		},
		quxiao:function(){
			this.industrylistShow = false;
		},

		save: function() {
			this.show = true;
			this.grxx = false;
			this.qzyx = false;
			this.zwpj = false;
		},
		grxxSave: function(e) {
			this.save();
			this.zwpj = $("#zwpj").html();

			//			console.log(this.birthday);
			var date = new Date();
			var month = (date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1);
			var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
			var update = date.getFullYear() + "-" + month + "-" + day;

			// LeanCloud - 当前用户
			// https://leancloud.cn/docs/leanstorage_guide-js.html#当前用户
			var currentUser = AV.User.current();
			var userid = currentUser.id; //获取用户id
			// LeanCloud - 对象
			// https://leancloud.cn/docs/leanstorage_guide-js.html#数据类型
			var product = AV.Object.createWithoutData('resume', this.objectid); //获取表

			product.set('userid', userid);
			product.set('update', update);
			product.set('username', this.userid);
			product.set('resumeName', this.resumeName);
			product.set('sex', this.sex);
			product.set('birthday', this.birthday);
			product.set('hukou', this.hukou);
			product.set('city', this.city);
			product.set('telephone', this.telephone);
			product.set('email', this.email);
			product.set('school', this.school);
			product.set('workplace', this.workplace);
			product.set('money', this.money);
			product.set('zwlb', this.jobtype);
			product.set('industry', this.hylb);
			product.set('zwpj', this.zwpj);
			product.save().then(function() {
				//上传成功
				console.log("添加成功")
			}, function(error) {
				console.log(error)
			})
		},
		isMan: function() {
			this.isman = true;
			this.iswoman = false;
			this.sex = "男";
		},
		isWoman: function() {
			this.iswoman = true;
			this.isman = false;
			this.sex = "女";
		}
	},
	created: function() {
		init();
		var _this = this;
		var objectid = get(geturlitem(location.search, "objectid"));
		var isNew = get(geturlitem(location.search, "isNew"));
		if(isNew) {
			this.grxx = true;
			this.show = false;
		}
		this.objectid = objectid;
		var query = new AV.Query('resume');
		query.get(objectid).then(function(success) {
			// 成功获得实例
			console.log(success)
			_this.resumeName = success.attributes.resumeName; //简历名称
			_this.username = success.attributes.username; //姓名
			_this.sex = success.attributes.sex; //性别（默认为男）
			_this.birthday = success.attributes.birthday; //生日
			_this.hukou = success.attributes.hukou; //户口
			_this.city = success.attributes.city; //居住城市
			_this.telephone = success.attributes.telephone; //手机号
			_this.email = success.attributes.email; //邮箱
			_this.school = success.attributes.school; //毕业学校
			_this.workplace = success.attributes.workplace; //工作地点
			_this.money = success.attributes.money; //期望薪资
			_this.jobtype = success.attributes.zwlb; //职位类别
			_this.industry = success.attributes.hylb; //行业类别
			_this.zwpj = success.attributes.zwpj; //自我评价
			if(success.attributes.sex == "男") {
				_this.isman = true;
				_this.iswoman = false;
			} else {
				_this.isman = false;
				_this.iswoman = true;
			}
		}, function(error) {
			// 异常处理
		});
	}
})